V4L_UTILS_VERSION=0.8.0

# These ones can be overriden from the cmdline

CFLAGS := -g -O1
CFLAGS += -Wall -Wpointer-arith
CXXFLAGS := $(CFLAGS)
CFLAGS += -Wstrict-prototypes -Wmissing-prototypes

PREFIX = /usr/local
LIBDIR = $(PREFIX)/lib
# subdir below LIBDIR in which to install the libv4lx libc wrappers
LIBSUBDIR = libv4l

# These ones should not be overriden from the cmdline

# Note the -I../.. this assumes all sources live in a 2 level dir hierarchy!
override CPPFLAGS += -I../../include -D_GNU_SOURCE
# This is the soname version
LIB_RELEASE = 0

# And last various rules

%.o: %.c
	$(CC) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CFLAGS) -o $@ $<

%.o: %.cpp
	$(CXX) -Wp,-MMD,"$*.d",-MQ,"$@",-MP -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<

%.so:
	$(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ $(LIBS_$*)
	ln -f -s $@.$(LIB_RELEASE) $@

%.a:
	$(AR) cqs $@ $^

clean::
	rm -f core core.[0123456789]* *~ *.o *.d *.a *.so* DEADJOE *.orig *.rej $(TARGETS)
